﻿using Compass.Wasm.Shared;
using Compass.Wasm.Shared.Wms;
using System.Collections.Generic;

namespace Compass.Wpf.ApiServices.Wms;

public interface IVendorService : IBaseService<VendorDto>
{
    Task<ApiResponse<VendorDto>> GetSingleByNumberAsync(string number);
    Task<ApiResponse<List<VendorDto>>> GetTop5ByKeywordAsync(string? keyword);
}
public class VendorService : BaseService<VendorDto>, IVendorService
{
    private readonly HttpRestClient _client;
    private const string ServiceName = "Vendor";
    public VendorService(HttpRestClient client) : base(client, ServiceName)
    {
        _client = client;
    }
    public async Task<ApiResponse<VendorDto>> GetSingleByNumberAsync(string number)
    {
        var request = new BaseRequest
        {
            Method = RestSharp.Method.Get,
            Route = $"api/{ServiceName}/Number?number={number}"
        };
        return await _client.ExecuteAsync<VendorDto>(request);
    }
    public async Task<ApiResponse<List<VendorDto>>> GetTop5ByKeywordAsync(string? keyword)
    {
        var request = new BaseRequest
        {
            Method = RestSharp.Method.Get,
            Route = $"api/{ServiceName}/Top5?keyword={keyword}"
        };
        return await _client.ExecuteAsync<List<VendorDto>>(request);
    }
}